
function g=logit_score_rewt(beta, x0, x1, pi);

%beta is a k x 1 vector of coefficients
%x1 is a (n1 x k) matrix of explanatory variables for the y=1 sample
%x0 is a (n0 x k) matrix of explanatory variables for the y=0 sample
%pi is a scalar; pi=P(Y=1)

%the output g is a 1 x k row vector of logit score values evaluated at beta

dim=size(x0);
n0=dim(1);

dim=size(x1);
n1=dim(1);

index0=x0*beta; %n0 x 1 vector 
index1=x1*beta; %n1 x 1 vector 

u=ones(size(beta')); % 1 x k

g = (pi/n1)*sum(  ( (1-Lambda(index1)) * u ).*x1  )  +  ((1-pi)/n0)*sum(  ( (-Lambda(index0)) * u ).*x0  );


%index=x*beta; %n x 1 vector 
%g=sum(     (  ( y-Lambda(index) ) * ones(size(beta'))  ).*x     );   
